//
//  StudentLoginController.m
//  projectBase
//
//  Created by 陈剑英 on 2017/7/7.
//  Copyright © 2017年 陈剑英. All rights reserved.
//

#import "StudentLoginController.h"
#import "StudentRegistController.h"


@interface StudentLoginController ()

@end

@implementation StudentLoginController

-(void) initUI
{
    [super initUI];
    [self setTopBgColor:[UIColor clearColor]];
    [self setBackBtnHide:YES];
    [self setTopTitle:@""];
    [self setTopLineHide:YES];
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIImageView *topImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth/2)];
    topImage.image = [UIImage imageNamed:@"dl_bg"];
    [self.view addSubview:topImage];
    
    UIImageView *iconImage = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenWidth/2-30, CGRectGetMaxY(topImage.frame)/2-38, 60, 76)];
    iconImage.image = [UIImage imageNamed:@"dl_logo"];
    [self.view addSubview:iconImage];
    
    UILabel *line1 = [self createLabel:CGRectMake(0, CGRectGetMaxY(topImage.frame)-7, ScreenWidth, 7) title:@"" fontSize:1 textColor:nil];
    line1.backgroundColor = MainColor;
    [self.view addSubview:line1];
    
    //账号
    UITextField *zhanghaoText = [[UITextField alloc] initWithFrame:CGRectMake(25, CGRectGetMaxY(topImage.frame)+43, ScreenWidth-50,60)];
//    zhanghaoText.secureTextEntry = YES;
    zhanghaoText.tag = 10000000;
    zhanghaoText.keyboardType = UIKeyboardTypeNumberPad;
    //    shoujihaoText.tag = SHOUJIHAOTAG;
    zhanghaoText.backgroundColor = [UIColor whiteColor];
    zhanghaoText.placeholder=@"请输入账号";
    zhanghaoText.returnKeyType = UIReturnKeySearch;
    //左视图
    UIView *zhanghao_view1 = [[UIView alloc] initWithFrame:CGRectMake(10, 0, 45, 60)];
    
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(10, 22, 16, 16)];
    image.image = [UIImage imageNamed:@"dl_11"];
    [zhanghao_view1 addSubview:image];
    
    zhanghaoText.leftView = zhanghao_view1;
    zhanghaoText.leftViewMode = UITextFieldViewModeAlways;
    zhanghaoText.font = [UIFont systemFontOfSize:17 weight:0.2];
    [self.view addSubview:zhanghaoText];
    
    UILabel *line2 = [self createLabel:CGRectMake(20, CGRectGetMaxY(zhanghaoText.frame), ScreenWidth-40, 1) title:@"" fontSize:1 textColor:nil];
    line2.backgroundColor = UIColorRGB(237);
    [self.view addSubview:line2];
    
    
    //密码
    UITextField *mimaText = [[UITextField alloc] initWithFrame:CGRectMake(25, CGRectGetMaxY(zhanghaoText.frame)+2, ScreenWidth-50,60)];
    mimaText.font = [UIFont systemFontOfSize:17 weight:0.2];
    mimaText.secureTextEntry = YES;
    mimaText.tag = 10000001;
    mimaText.backgroundColor = [UIColor whiteColor];
    mimaText.placeholder=@"请输入密码";
    mimaText.returnKeyType = UIReturnKeySearch;
    //左视图
    UIView *mima_view1 = [[UIView alloc] initWithFrame:CGRectMake(10, 0, 45, 60)];
    
    UIImageView *mima_image = [[UIImageView alloc]initWithFrame:CGRectMake(10, 22, 16, 16)];
    mima_image.image = [UIImage imageNamed:@"dl_11"];
    [mima_view1 addSubview:mima_image];
    //右视图
    UIView *rightView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 21, 60)];
    UIImageView *right_image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 22, 21, 16)];
    right_image.image = [UIImage imageNamed:@"dl_7"];
    [rightView addSubview:right_image];
    
    mimaText.leftView = mima_view1;
    mimaText.leftViewMode = UITextFieldViewModeAlways;
    mimaText.rightView = rightView;
    mimaText.rightViewMode = UITextFieldViewModeAlways;
    [self.view addSubview:mimaText];
    
    UILabel *line3 = [self createLabel:CGRectMake(20, CGRectGetMaxY(mimaText.frame), ScreenWidth-40, 1) title:@"" fontSize:1 textColor:nil];
    line3.backgroundColor = UIColorRGB(237);
    
    
    
    
    [self.view addSubview:line3];
    
    //忘记密码
    UIButton *wangjiBtn = [self createBtn:CGRectMake(CGRectGetMaxX(line3.frame)-85, CGRectGetMaxY(mimaText.frame)+1, 100, 30) title:@"忘记密码?" iconImage:nil backgroundImage:nil tag:10000004 textColor:UIColorRGB(120)];
    wangjiBtn.titleLabel.textAlignment = NSTextAlignmentRight;
    wangjiBtn.backgroundColor = [UIColor whiteColor];
    wangjiBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    [self.view addSubview:wangjiBtn];

    
    


    UIButton *loginBtn = [self createBtn:CGRectMake(13, CGRectGetMaxY(mimaText.frame)+70, ScreenWidth-26, 50) title:@"登  录" iconImage:nil backgroundImage:nil tag:10000002 textColor:[UIColor whiteColor]];
    loginBtn.backgroundColor = MainColor;
    loginBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:0.2];
    loginBtn.layer.cornerRadius = 25.0;
    [self.view addSubview:loginBtn];
    
    UIButton *registBtn = [self createBtn:CGRectMake(13, CGRectGetMaxY(loginBtn.frame), ScreenWidth-26, 50) title:@"注  册" iconImage:nil backgroundImage:nil tag:10000003 textColor:MainColor];
    registBtn.backgroundColor = [UIColor whiteColor];
    registBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:0.2];
    registBtn.layer.cornerRadius = 25.0;
    [self.view addSubview:registBtn];
}

-(void)btnAction:(id)sender
{
    UIButton *btn  = (UIButton *)sender;
    NSInteger tag = [btn tag];
    
    UITextField *zhanghaoText = [self.view viewWithTag:10000000];
    UITextField *mimaText = [self.view viewWithTag:10000001];
    
    
    //登陆
    if(tag == 10000002)
    {
        
    }
    //注册
    else if(tag == 10000003)
    {
        StudentRegistController *vc = [StudentRegistController new];
        [[ViewManager shareInstance].NavigationController pushViewController:vc animated:YES];
    }
    //忘记密码
    else if(tag == 10000004)
    {
        
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
